package com.orkasgb.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.orkasgb.common.CommonResult;
import com.orkasgb.entity.OrkasgbRoleEntity;
import com.orkasgb.service.IOrkasgbRoleService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

/**
 * 角色信息表(TOrkasgbRole)表控制层
 *
 * @version 1.0.0
 * @since 2024-10-09 11:36:59
 */
@RestController
@RequestMapping("orkasgbRole")
public class OrkasgbRoleController {
    /**
     * 服务对象
     */
    @Resource
    private IOrkasgbRoleService orkasgbRoleService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("getOrkasgbRole/{id}")
    public CommonResult<OrkasgbRoleEntity> getOrkasgbRole(@PathVariable("id") Serializable id) {
        return CommonResult.ofSuccess(orkasgbRoleService.getOrkasgbRole(id));
    }

    /**
     * 通过条件查询多条数据
     *
     * @param orkasgbRole 实体查询参数
     * @return 单条数据
     */
    @GetMapping("getOrkasgbRoleList")
    public CommonResult<List<OrkasgbRoleEntity>> getOrkasgbRoleList(@ModelAttribute OrkasgbRoleEntity orkasgbRole) {
        return CommonResult.ofSuccess(orkasgbRoleService.getOrkasgbRoleList(orkasgbRole));
    }

    /**
     * 通过条件查询多条数据(分页查询)
     *
     * @param orkasgbRole 查询参数
     * @return 单条数据
     */
    @GetMapping("getOrkasgbRolePageDataList")
    public CommonResult<IPage<OrkasgbRoleEntity>> getOrkasgbRolePageDataList(@ModelAttribute OrkasgbRoleEntity orkasgbRole) {
        return CommonResult.ofSuccess(orkasgbRoleService.getOrkasgbRolePageDataList(orkasgbRole));
    }

    /**
     * 新增数据
     *
     * @param orkasgbRole 实体对象
     * @return 新增结果
     */
    @PostMapping("addOrkasgbRole")
    public CommonResult<Integer> addOrkasgbRole(@RequestBody OrkasgbRoleEntity orkasgbRole) {
        return CommonResult.ofSuccess(orkasgbRoleService.addOrkasgbRole(orkasgbRole));
    }

    /**
     * 修改数据
     *
     * @param orkasgbRole 实体对象
     * @return 修改结果
     */
    @PutMapping("updateOrkasgbRole")
    public CommonResult<Integer> updateOrkasgbRole(@RequestBody OrkasgbRoleEntity orkasgbRole) {
        return CommonResult.ofSuccess(orkasgbRoleService.updateOrkasgbRole(orkasgbRole));
    }

    /**
     * 修改或者新增数据
     *
     * @param orkasgbRoleList 实体对象
     * @return 操作结果
     */
    @PostMapping("addOrUpdateOrkasgbRole")
    public CommonResult<Integer> addOrUpdateOrkasgbRole(@RequestBody List<OrkasgbRoleEntity> orkasgbRoleList) {
        return CommonResult.ofSuccess(orkasgbRoleService.addOrUpdateOrkasgbRole(orkasgbRoleList));
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @DeleteMapping("deleteOrkasgbRoleByIds")
    public CommonResult<Integer> deleteOrkasgbRoleByIds(@RequestParam("idList") List<Long> idList) {
        return CommonResult.ofSuccess(orkasgbRoleService.deleteOrkasgbRoleByIds(idList));
    }
}

